package com.fadadianqi.goods.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.goods.dao.BrandCategoryRelationDAO;
import com.fadadianqi.goods.model.BrandCategoryRelation;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by aroot on 2/9/14.
 */
@Component
public class BrandCategoryRelationImpl extends GenericDAOSuport<String, BrandCategoryRelation> implements BrandCategoryRelationDAO {

    @Override
    protected Class<?> getObjectClass() {
        return BrandCategoryRelation.class;
    }

    @Override
    protected String getTableName() {
        return "brand_category_relation";
    }

    @Override
    public BrandCategoryRelation getByBrandIdAndCategoryId(String brandId, String categoryId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("brandId", brandId);
        map.put("categoryId", categoryId);
        return super.getByPropertys(map);
    }

    @Override
    public List<BrandCategoryRelation> findByBrandId(String bid) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("brandId", bid);
        return super.findByPropertys(map);
    }

    @Override
    public List<BrandCategoryRelation> findByCategoryId(String cid) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("categoryId", cid);
        return super.findByPropertys(map);
    }
}
